package entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

@Entity
@Table(name = "APPLICATIONUSER")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Applicationuser.findAll", query = "SELECT a FROM Applicationuser a"),
    @NamedQuery(name = "Applicationuser.findById", query = "SELECT a FROM Applicationuser a WHERE a.id = :id"),
    @NamedQuery(name = "Applicationuser.findByUsername", query = "SELECT a FROM Applicationuser a WHERE a.username = :username"),
    @NamedQuery(name = "Applicationuser.findByEncryptedpwd", query = "SELECT a FROM Applicationuser a WHERE a.encryptedpwd = :encryptedpwd")})
public class Applicationuser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "USERNAME")
    private String username;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "ENCRYPTEDPWD")
    private String encryptedpwd;
    @JoinColumn(name = "PERSONID", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Person personid;

    public Applicationuser() {
    }

    public Applicationuser(Integer id) {
        this.id = id;
    }

    public Applicationuser(Integer id, String username, String encryptedpwd) {
        this.id = id;
        this.username = username;
        this.encryptedpwd = encryptedpwd;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getEncryptedpwd() {
        return encryptedpwd;
    }

    public void setEncryptedpwd(String encryptedpwd) {
        this.encryptedpwd = encryptedpwd;
    }

    public Person getPersonid() {
        return personid;
    }

    public void setPersonid(Person personid) {
        this.personid = personid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Applicationuser)) {
            return false;
        }
        Applicationuser other = (Applicationuser) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Applicationuser[ id=" + id + " ]";
    }
    
}
